package br.com.projeto.hibernatedao;

import java.util.List;

import org.hibernate.Session;

import br.com.projeto.dao.ProductDAO;
import br.com.projeto.entities.Product;


public class ProductHibernateDAO implements ProductDAO{
	
	private Session session;

	public Session getSession() {
		return session;
	}

	public void setSession(Session session) {
		this.session = session;
	}

	@Override
	public void saveProduct(Product product) {
		this.session.save(product);		
	}

	@Override
	public void updateProduct(Product product) {
		this.session.update(product);
	}

	@Override
	public void deleteProduct(Product product) {
		this.session.delete(product);		
	}

	@SuppressWarnings("unchecked")
	@Override
	public List<Product> listAllProducts() {
		return getSession().createCriteria(Product.class).list();
	}

}
